from base import Base
from selenium.webdriver.common.by import By
from time import sleep

class ChuFang(Base):

    souchangtag = (By.XPATH,'/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.drawerlayout.widget.DrawerLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TabHost/android.widget.LinearLayout/android.widget.TabWidget/android.widget.RelativeLayout[3]/android.widget.LinearLayout/android.widget.ImageView')
    caidan = 'new UiSelector().text("菜单")'
    tianjiaanniu = (By.XPATH,'/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.drawerlayout.widget.DrawerLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[3]/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.ImageView[2]')
    biaoti = (By.XPATH,'//android.widget.EditText[@text="必填·20字以内"]')
    miaoshu = (By.XPATH,'//android.widget.EditText[@resource-id="com.xiachufang:id/et_describe"]')
    chuangjian = 'new UiSelector().resourceId("com.xiachufang:id/tv_right")'
    daunyan = (By.ID,'com.xiachufang:id/navigation_bar_title_layout')

    def chuangjiancaidanyewu(self,title,miaoshu):
        self.find_ele(self.souchangtag).click()
        sleep(2)
        self.find_ele(self.caidan).click()
        sleep(2)
        self.find_ele(self.tianjiaanniu).click()
        sleep(2)
        self.find_ele(self.biaoti).send_keys(title)
        sleep(2)
        self.find_ele(self.miaoshu).send_keys(miaoshu)
        sleep(2)
        self.find_ele(self.chuangjian).click()
        sleep(2)

